<template>
  <div>
    <h1>学生录入</h1>
    <h3>欢迎您{{ biao.username }}!</h3>
    <p>学生姓名：<input type="text" v-model="form.name">
    学生年龄：<input type="text" v-model="form.age">   <button @click="ss">提交</button></p>
    <router-link :to="{name:'no_stu'}">点击查看未分班的学生</router-link>
  </div>
</template>

<script>
export default {
  name: "stu",
  data() {
    return {
      userid: localStorage.getItem('userid'),
      biao: {},
      form: {'teacher': localStorage.getItem('userid')}
    }
  },
  methods: {
    get_tea() {
      this.$axios.get('users/TeaAPI/?id=' + this.userid)
        .then(res => {
          this.biao = res.data.list
        })
    },
    ss() {
      this.$axios.post('users/StusAPI/', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('ok')
            this.form = {}
          } else {
            alert('no')
          }
        })
    }
  },
  mounted() {
    this.get_tea()
  }
}
</script>

<style scoped>

</style>
